-- flee
-- created by panyl
-- N回合后逃跑

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,

    record = function(target, prop, path)
        return false;
    end,

    -- 每回合触发
    trigger = function(who, prop, arg)
        -- 一定是要怪物
        if who.type ~= OBJECT_TYPE_MONSTER then
            return false;
        end

        local grid = DungeonM.getGridByPos(who:getPos());
        local round = CombatM.getRound();
        local openRound = grid.openRound or 0;

        if round - openRound < tonumber(prop[2]) then
            return false;
        end

        -- 逃跑
        who:escape();

        -- 直接无效
        grid:changeState(GRID_STATE_DISABLE);
        grid.bonus = nil;
        EventMgr.fire(event.MONSTER_FLEE, {["pos"] = who:getPos(), });

        return true;
    end,

    clear = function(who, prop)
        -- 同步清除掉改变技能间隔的属性
        PropM.deletePropById(who, "special", "add_cd");
    end,
};
